package com.ocom.mqsimple.business.excel.impl;


import com.ocom.mqsimple.business.excel.ProductService;
import com.ocom.mqsimple.utils.RabbitProductUitl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class ProductServiceImpl implements ProductService {



	@Autowired
	private RabbitProductUitl rabbitProductUitl;

	/**
	 * 模拟支付接口
	 *  支付完成后会调用：
	 *      1.修改订单为支付状态接口
	 *      2.减库存接口
	 */
	@Transactional
	public void makePayments(String msg) {
		//TODO 数据库操作

		if(false){
			throw new RuntimeException("订单错误。。。。");
		}
		//模拟支付
		System.out.println("支付完成啦啦啦。。。。。。。。。");

		//TODO 数据库操作

		if(false){
			throw new RuntimeException("订单状态修改失败");
		}
		//消息队列调用减库存接口  优先级越高越先执行完
		rabbitProductUitl.send(msg,5);

	}
}
